package com.danger.Activity.Play;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
import com.danger.Activity.R;
import com.danger.Model.bean.VideoBean;
import java.io.File;

public class PlayActivity extends AppCompatActivity {

    private VideoView videoView;
    private MediaController controller;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);

        init();
    }

    private void init() {
        videoView = (VideoView) findViewById(R.id.videoView);
        controller = new MediaController(this);
        String path = ((VideoBean) (getIntent().getSerializableExtra("videoBean"))).getDate();
        File file = new File(path);
        if (file.exists()) {
            videoView.setVideoPath(file.getAbsolutePath());
            videoView.setMediaController(controller);
            videoView.setFitsSystemWindows(true);
            controller.setMediaPlayer(videoView);
            controller.setPrevNextListeners(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Toast.makeText(PlayActivity.this, "上一个", Toast.LENGTH_SHORT).show();
                }
            }, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(PlayActivity.this, "下一个", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
}